import Vue from 'vue'
import Router from 'vue-router'
import Main from '../views/Main'
import News from '../components/News'
import Article from '../components/Article'
import Comments from '../components/Comment'
import Cate from '../components/Cate'
import Me from '../components/Me'
import Login from '../components/Login'
import Register from '../components/Register'

Vue.use(Router)
var router = new Router({
  mode: 'hash',
  routes: [
    {
      path: '/',
      redirect: '/main'
    },
    {
      path: '/main',
      component: Main,
      children: [
        {
          path: '',
          redirect: 'news'
        },
        {
          path: 'news',
          component: News
        },
        {
          path: 'article/:id',
          component: Article
        },
        {
          path: 'article/:id/comments',
          component: Comments
        },
        {
          path: 'cate',
          component: Cate
        },
        {
          path: 'me',
          component: Me
        },
        {
          path: 'login',
          component: Login
        },
        {
          path: 'register',
          component: Register
        }
      ]
    }
  ]
})

Router.prototype.goBack = function () { 
  　　this.isBack = true
  　　window.history.go(-1)
}
export default router
